<?php
class experience{
	var $id_experience;
	var $post;
	var $company;
	var $year;
	var $responsibility;
	var $id_user;
	
	var $mnum;
	var $res;

	function experience(){}
	
	function get_experience($user_id){
		$this->res = mysql_query("SELECT * FROM experience where id_user_fkn = $user_id;");
		$this->mnum = mysql_num_rows($this->res);
	}
	
	function fillinfo(){
			if($obj = mysql_fetch_object($this->res)){
			$this->id_experience = $obj->id_experience;
			$this->post = $obj->post;
			$this->company = $obj->company;
			$this->year = $obj->year;
			$this->responsibility = $obj->responsibility;
			$this->id_user = $obj->id_user_fkn;
			return true;
			}else return false;
	}
	
	function add(){
		mysql_query("INSERT INTO experience(post,company,year,responsibility,id_user_fkn)
		 VALUES
		  ('$this->post', '$this->company', '$this->year' , '$this->responsibility', '$this->id_user');");		
		return  mysql_insert_id();
	}
	
	function edit(){
		//echo "UPDATE users SET  guard_password_tx='$this->password', guard_lastname_tx='$this->lastname', guard_firstname_tx='$this->firstname', guard_phone_tx='$this->phone', guard_mail_tx='$this->mail', guard_cotier_stage_n='$this->stagecotier', guard_gender_n='$this->gendre', guard_hauturier_n='$this->hauturier', guard_cotier_n='$this->cotier', guard_carte_verte_n='$this->carte' WHERE guard_id_n=$this->id;";
		return mysql_query("
		UPDATE cursus SET  
		    level='$this->level', etablissement='$this->etablissement', year='$this->year', description='$this->description' 
		WHERE
		    id_cursus = $this->id_cursus");
	}
	
	function drop(){
		echo "DELETE FROM cursus WHERE id_cursus = $this->id_cursus;";
		return  mysql_query("DELETE FROM cursus WHERE id_cursus = $this->id_cursus;");
		}
		
function show_add_form(){
	?>
	<form class="cmxform" method="POST" action="index.php">
	<fieldset>
		<legend>Cursus</legend>
		<p>
			<label for="level">Post </label>
			<input id="post" name="post"/>
		</p>
		<p>
			<label for="company">Etablissement</label>
			<input id="company" name="company"/>
		</p>
		<p>
			<label for="year">Annee</label>
<!--			<input name="year" id="year" class="calendarSelectDate"/>-->
			<input type='text' name='year_exp'  id='year_exp' onClick="setYears(1930, 2015); showCalender(this, 'year_exp');">
		</p>
		<p>
			<label for="resp">Responsibilite</label>
			<textarea name="resp" id="resp"></textarea>
		</p>
		<p>
			<input class="submit" type="button" value="Submit" name="sbt" onclick="add_exp('<?=$this->id_user?>')" />
		</p>
	</fieldset>
	
</form>	
<div id="exp_res" class="div_note"> </div>

	<?php
}//----------------------------------------end of show form function 

}
?>

